package system.model.converter;

import com.google.common.collect.Lists;
import common.model.po.SysRoleAuthority;
import system.model.compare.SysRoleAuthorityCompare;

import java.util.List;

/**
 * @author 米泽鹏
 * @since 2022-3-13 下午 11:40
 */
public class SysRoleAuthorityConverter {

	public static List<SysRoleAuthorityCompare> poListToCompareList(List<SysRoleAuthority> poList) {
		List<SysRoleAuthorityCompare> compareList = Lists.newArrayList();
		for (SysRoleAuthority po : poList) {
			SysRoleAuthorityCompare compare = poToCompare(po);
			compareList.add(compare);
		}
		return compareList;
	}

	public static List<SysRoleAuthority> compareListToPoList(List<SysRoleAuthorityCompare> compareList) {
		List<SysRoleAuthority> poList = Lists.newArrayList();
		for (SysRoleAuthorityCompare compare : compareList) {
			SysRoleAuthority po = compareToPo(compare);
			poList.add(po);
		}
		return poList;
	}

	public static SysRoleAuthorityCompare poToCompare(SysRoleAuthority sysRoleAuthority) {
		if (sysRoleAuthority == null) {
			return null;
		}
		SysRoleAuthorityCompare sysRoleAuthorityCompare = new SysRoleAuthorityCompare();
		sysRoleAuthorityCompare.setRoleId(sysRoleAuthority.getRoleId());
		sysRoleAuthorityCompare.setAuthId(sysRoleAuthority.getAuthId());
		sysRoleAuthorityCompare.setId(sysRoleAuthority.getId());
		return sysRoleAuthorityCompare;
	}

	public static SysRoleAuthority compareToPo(SysRoleAuthorityCompare sysRoleAuthorityCompare) {
		if (sysRoleAuthorityCompare == null) {
			return null;
		}
		SysRoleAuthority sysRoleAuthority = new SysRoleAuthority();
		sysRoleAuthority.setRoleId(sysRoleAuthorityCompare.getRoleId());
		sysRoleAuthority.setAuthId(sysRoleAuthorityCompare.getAuthId());
		sysRoleAuthority.setId(sysRoleAuthorityCompare.getId());
		return sysRoleAuthority;
	}

}
